<?php
require_once "admin_header.php";
$data=new Database;
$user_id=$_GET['user_id'];
$level_id=$_GET['level_id'];

$list_level=$muser->show_level();
$sql="select * from user where user_id=".$user_id;
$data->query($sql);
$sele=$data->fetch();

if(isset($_POST['btupdate']))
{
	$level= $_POST['txtlevel'];
	$sql="UPDATE user
			SET level_id = $level
			WHERE user_id = $user_id";
	$data->query($sql);
	echo "<script> window.location='admin_phanquyen.php'</script>";
}

?>
<div class="heading">
    <a>sửa tài khoản</a>
</div>

<div class="content_page">
	<form method="post" enctype="multipart/form-data" name="fupdate">
        <table border="1">
            <td>Tên tài khoản:</td>
            <td><?php echo $sele['user_name'] ?></td>
            <td>
                <select name="txtlevel" id="txtlevel" style="height:auto" >
                    <?php
                       
                        foreach($list_level as $k)
                        {
                            if($k["level_id"]==1)
                                $lv= "Quản trị";
                            else
                                $lv= "Quản trị viên";
                            
                            if($k["level_id"]==$level_id)
                                echo "<option value='$k[level_id]' selected='selected'>$lv</option>";
                            else
                                echo "<option value='$k[level_id]'>$lv</option>";
                        }
                        
                    ?>
                </select>
            </td>
            <td>
                <input type="submit" name="btupdate" value="Cập Nhật">
            </td>
            <tr>
                <td colspan="4">
                </td>
            </tr>
        </table>
      </form>
</div>
<?php
	require_once "admin_footer.php";
?>